package com.apes.scm.rbac.repository;

import com.apes.framework.jpa.repository.CustomRepository;
import com.apes.scm.rbac.model.LocalPermitItem;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface LocalPermitItemRepository extends CustomRepository<LocalPermitItem, String> {

    @Query(value = "SELECT c.* " +
            "  FROM aut_posts a, aut_local_permit b, aut_local_permit_item c " +
            " WHERE a.local_permit_id = b.id " +
            "   AND b.id = c.local_permit_id " +
            "   AND a.id = :postId " +
            "   AND c.type = :type " +
            "   AND c.purpose = :purpose", nativeQuery = true)
    List<LocalPermitItem> find(@Param("postId") String postId, @Param("purpose") String purpose, @Param("type") String type);
}
